package cn.org.itool.ws.framework.protocol.factory;

import cn.org.itool.ws.framework.protocol.service.ProtocolService;
import cn.org.itool.ws.framework.protocol.service.impl.ProtocolBizServiceImpl;
import cn.org.itool.ws.framework.protocol.service.impl.ProtocolPomeloServiceImpl;
import lombok.extern.log4j.Log4j2;

@Log4j2
public class ProtocolServiceFactory {


    private static final ProtocolService[] protocolServiceList = new ProtocolService[]{
            new ProtocolBizServiceImpl(),
            new ProtocolPomeloServiceImpl()
    };

    public static ProtocolService getInstance(Integer protocolType){
        for (ProtocolService protocolService : protocolServiceList) {
            if(protocolService.type().getCode().equals(protocolType)){
                return protocolService;
            }
        }

        log.error("ProtocolService is null : {}", protocolType);
        return null;
    }


}
